//
//  QZMyOrderCell.m
//  WeiWeiHaircut
//
//  Created by 上官惠阳 on 15/12/11.
//  Copyright © 2015年 超群. All rights reserved.
//

#import "QZMyOrderCell.h"
#import "UIView+RoundView.h"
#import "AppointmentModel.h"
#import "UIImageView+WebCache.h"
#import "QZDateManager.h"
@implementation QZMyOrderCell

- (void)awakeFromNib {
    [self.contentView setlineFrame:CGRectMake(0, 35, WIDTH, 0.3) lineColor:[UIColor lightGrayColor] lineAlpha:0.5];
    [self.contentView setlineFrame:CGRectMake(20, 100, WIDTH - 20, 0.3) lineColor:[UIColor lightGrayColor] lineAlpha:0.3];
    
    [self.iconView setCornerRadius:4];
    self.contactBtn.backgroundColor = SBpurpleColor;
    [self.contactBtn setCornerRadius:4];
    self.overButton.backgroundColor = SBpurpleColor;
    [self.overButton setCornerRadius:4];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setModel:(AppointmentModel *)model{
    _model = model;
    
    self.orderCodeLabel.text = model.appoint_num;
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.shop_photo] placeholderImage:[UIImage imageNamed:@"1123.jpg"]];
    self.statusLabel.text = [self stringWithStatus:model.display];
    
    NSString *str =nil;
    
    if (model.display == 0) {
        str = @"支付押金之后才能预约哟";
    }else if (model.display ==4){
        str =@"等待抢单中...";
    }
    self.orderTitleLabel .text = model.shop_name?model.shop_name:str;
    
    self.addressLabel.text = model.appoint_address?model.appoint_address:str;
    self.orderTimeLabel.text =model.time?[[QZDateManager sharedDateManager] secondToStringTIme:model.appoint_time]:str;
    self.orderTypeLabel.text  = model.appoint_cate_name?model.appoint_cate_name:str;
    
    for (int i = 0; i<self.starImageViewArr.count; i++) {
        UIImageView *imageView= self.starImageViewArr[i];
        if (i<model.shop_evaluate) {
            imageView.image = [UIImage imageNamed:@"star1"];
        }else{
            imageView.image = [UIImage imageNamed:@"star2"];
        }
        
    }
}

-(NSString *)stringWithStatus:(NSInteger)index{
    NSString *string = nil;
    switch (index) {
        case 0:
            string = @"未付押金";
            break;
        case 1:
            string = @"待服务";
            break;
        case 2:{
            if (self.model.appoint_evaluate) {
                string = @"已评价";
            }else{
                string = @"待评价";
            }
            
        }break;
        case 3:
            string = @"纠纷";
            break;
        case 4:
            string = @"未受理";
            break;
        case 5:
            string = @"未支付";
            break;
        default:
            break;
    }

    return string;
 
}
@end
